package com.touzhijia.authority.mapper;

import com.touzhijia.authority.domain.dto.request.RoleQueryByUserReq;
import com.touzhijia.authority.domain.dto.request.RoleQueryReq;
import com.touzhijia.authority.domain.dto.response.RoleByUserRes;
import com.touzhijia.authority.domain.entity.Role;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * 作者： lzw<br/>
 * 创建时间：2018-03-14 17:06 <br/>
 */
public interface RoleMapper extends Mapper<Role> {

    Role getByName(@Param("name") String name);

    List<Role> findRole(RoleQueryReq queryReq);

    List<RoleByUserRes> findRoleByUser(RoleQueryByUserReq queryReq);

    int existsPermission(@Param("roleName") String roleName, @Param("permission") String permission);

    int addPermission(@Param("roleName") String roleName, @Param("permission") String permission);

    List<Role> findUserAllRole(@Param("username") String username);

    /**
     * 删除 role_permission
     */
    int delPermission(@Param("roleName") String roleName, @Param("permission") String permission);

    /**
     * 删除 role_permission
     */
    int deleteByPermission(@Param("permission") String permission);

    /**
     * 删除 role_permission
     */
    int deleteByRoleName(@Param("roleName") String roleName);

    /**
     * 删除 role
     */
    int deleteByName(@Param("name") String name);
}
